$(function(){
  // $('body').addClass('g-loading');
  // http://api-t.chinaqljf.com/broker/brokerInfo?uid=5339
    var c={
        ajax:'/broker/brokerInfo',
        data:{ uid:5339}
    }

    function initApp(cb){
        if(c.data.uid>0){
            cb()
        }else{
            XT.getUserInfo(function(info){
                c.data.uid=info.id;
                cb();
            })
        }
    }

    initApp(function(){
        var store=new Vuex.Store({
            state:{
                 data:{
                  higherUserInfo:{},
                  inviteNum:'',
                  directInviteNum:'',
                  indirectInviteNum:'',
                  brokerLevelInfo:[
                      {level:'',inviteNum:''},
                      {level:'',inviteNum:''},
                      {level:'',inviteNum:''},
                      {level:'',inviteNum:''},
                      {level:'',inviteNum:''},   
                  ],
                },
                showloading:''
            },
            actions:{
                'get_information':function({commit,state},params){
                    XT.jsonp({
                      url:c.ajax,
                      data:params.data,
                      success:function(data){
                          // params.callback(data)
                          commit('set_information',data)
                      }
                    })
                }
            },
            mutations:{
               'set_information':function(state,data){
                   console.log(data.inviteNum)
                   state.data=data;
                   state.showloading=true
                   console.log(data.brokerLevelInfo)
               }

            }
        })

        var App=new Vue({
          el:'#app',
          store:store,
          data:{
             
          },
          methods:{
          },
          computed:{
             'higherUserInfo':function(){
              return this.$store.state.data.higherUserInfo
             },
             'inviteNum':function(){
              return this.$store.state.data.inviteNum;
             },
             'directInviteNum':function(){
              return this.$store.state.data.directInviteNum;
             },
             'indirectInviteNum':function(){
              return this.$store.state.data.indirectInviteNum;
             },
              'brokerLevelInfo':function(){
                  return this.$store.state.data.brokerLevelInfo;
              },
              'showloading':function(){
                  return this.$store.state.showloading;
              },
          },
          created:function(){
              this.$store.dispatch('get_information',{
                  data:c.data,
              });
          }
      })

    })
    

})